package com.bhkj.pdjhforotherapp.common.work;


import androidx.work.ExistingPeriodicWorkPolicy;
import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager;

import java.util.concurrent.TimeUnit;

public class WorkHelper {
    private static String CLEAR_CACHE = "clear_CACHE";

    /**
     * 启动定时任务清除系统 /data/log下的日志
     */
    public static void launcherWorkWithCache() {
        PeriodicWorkRequest build = new PeriodicWorkRequest.Builder(ClearCacheWork.class, 15, TimeUnit.MINUTES).build();
        WorkManager.getInstance()
                .enqueueUniquePeriodicWork(CLEAR_CACHE, ExistingPeriodicWorkPolicy.KEEP, build);
    }

    /**
     * 取消定时任务
     */
    public static void cancelWorkWithCache() {
        WorkManager.getInstance()
                .cancelUniqueWork(CLEAR_CACHE);
    }
}
